APP_DIR = ../../../../app

include $(APP_DIR)/Rules.make
include $(APP_DIR)/odin_inc

NAME = $(notdir $(CURDIR))
LIB_NAME = lib$(NAME).a
RELEASE_DIR = ../../lib/
HEADER_DIR  = ../../include/
HIMPP_DIR = ../mpp_master

# archiver and its options
ARFLAGS = -r

CROSS_COMPILE = $(COMPILE_PREFIX)
EXE_DIR = .

ifeq ($(BUILD_TYPE), release)
    CFLAGS		= -DNDEBUG
    CFLAGS		+= -O2
else
    CFLAGS		= -g
endif


HEADERS = $(wildcard *.h)

LINTFLAGS := +posixlib -linelen 160 
LINTFLAGS += -exportlocal 	# 函数未被本模块之外函数引用
LINTFLAGS += -likelybool	# boolean bool int等类型
LINTFLAGS += -nullpass 		# pthread_mutex_t函数：参数含NULL


INCDIRS := -I. -I$(COMPILE_INCLUDE) -I$(HEADER_DIR)
INCDIRS += $(ADD_SUBLIB_INC)
INCDIRS += -I $(HIMPP_DIR)/include \
           -I $(HIMPP_DIR)/extdrv/tlv320aic31 \
           -I $(HIMPP_DIR)/sample/common

CFLAGS +=  $(ODIN_INC_C_FLAG)
CFLAGS +=  -static $(INCDIRS) 
CFLAGS +=  -pthread
					
objects := $(patsubst %.c,%.o,$(wildcard *.c))

					
all: $(LIB_NAME)

$(LIB_NAME) : $(objects)
	$(AR) $(ARFLAGS) $@  $^

$(objects): %.o: %.c $(HEADERS)
	$(CROSS_COMPILE)gcc -c $(CFLAGS) $(LDFLAGS) $< -o $@

install:
	cp *.h  $(HEADER_DIR)
	cp $(LIB_NAME) $(RELEASE_DIR)


clean:
	rm -f $(objects) $(LIB_NAME)

distclean: clean
	rm -f $(objects)

lint:
	@echo -----------------------------------------------------------
	splint  $(LINTFLAGS) $(INCDIRS) *.c
	
lintw: 
	@echo -----------------------------------------------------------
	-splint -weak $(LINTFLAGS) $(INCDIRS) *.c
 
lintc: 
	@echo -----------------------------------------------------------
	-splint -checks $(LINTFLAGS) $(INCDIRS) *.c
 
lints: 
	@echo -----------------------------------------------------------
	-splint -strict $(LINTFLAGS) $(INCDIRS) *.c
